<template>
	<view>
		<view class="flex flex-direction align-center justify-center">
			<input class="inp" placeholder-class="inpplace" placeholder="几米晓晓..." v-model="nickName"/>
			<view class="btn" @tap='updateUser'>确认</view>
		</view>
	</view>
</template>

<script>
	var api = require('@/components/api.js');
	export default {
		data() {
			return {
				user:'',
				nickName:''
			}
		},
		onLoad() {
			this.user = uni.getStorageSync('user')
			if(this.user){
				this.nickName = this.user.nick_name
			}
		},
		methods: {
			updateUser(){
				api.post({
					url: 'User/PostUserNikenameEdit?user_id='+this.user.user_id,
					data: {
						nick_name: this.nickName,
						sex:this.user.sex,
					},
					success: data => {
						console.log(JSON.stringify(data))
						if (data.ErrCode == 0) {
							uni.showModal({
								title:'提示',
								content:'修改成功'
							})
							uni.navigateTo({
								url:'/module/my/myInfor/myInfor'
							})
						}
					}
				});
			},
		}
	}
</script>

<style lang="scss" scoped>
	.btn{
		text-align: center;
		width: 560upx;
		line-height: 70upx;
			height: 70upx;
			background-color: $btn-bground;
			border-radius: 35upx;
			color: #fff;
			font-size: 28upx;
			margin-top: 36upx;
	}
	.inpplace{
		color: #666666;
	}
	.inp{
		margin-top: 54upx;
		font-size: 28upx;
		width: 560upx;
			height: 72upx;
			background-color: #f0f0f0;
			border-radius: 36upx;
			padding-left: 38upx;
			box-sizing: border-box;
	}
	page{
		background-color: #fff;
	}
</style>
